package org.dromara.study.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.study.domain.vo.BookBorrowingRecordsVo;
import org.dromara.study.service.BookBorrowingRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/bookBorrowingRecords")
public class BookBorrowingRecordsController {

    @Autowired
    private BookBorrowingRecordsService bookBorrowingRecordsService;

    @GetMapping("/page")
    public R<Page<BookBorrowingRecordsVo>> getPage(PageQuery query, BookBorrowingRecordsVo bookBorrowingRecordsVo){
        return R.ok(bookBorrowingRecordsService.getPage(query,bookBorrowingRecordsVo));
    }

    @PostMapping("/add")
    public R<String> add(@RequestBody BookBorrowingRecordsVo bookBorrowingRecordsVo){
        bookBorrowingRecordsService.add(bookBorrowingRecordsVo);
        return R.ok("新增成功");
    }

    @PostMapping("/returnBook")
    public R<String> returnBook(@RequestBody BookBorrowingRecordsVo bookBorrowingRecordsVo){
        bookBorrowingRecordsService.returnBook(bookBorrowingRecordsVo);
        return R.ok("归还成功");
    }
}
